package net.pinnoocle.playdao.entity.page;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Optional;

/**
 * 基于模型的分页基类
 *
 * @author ye
 * @since 2021-09-01 15:42:37
 */
@Data
@ApiModel("分页基类")
public class BasePageParam {

  @ApiModelProperty("当前页 默认第一页")
  private int page = 1;

  @ApiModelProperty("每页显示条数 默认10条")
  private int pageSize = 10;

  @ApiModelProperty("搜索的内容")
  private String searchBody;

  @ApiModelProperty("排序列")
  private String orderByColumn;

  @ApiModelProperty("升序asc,降序desc")
  private String isAsc;

  public void setPage(Integer page) {
    this.page = Optional.ofNullable(page).filter(p -> p > 0).orElse(1);

  }

  public void setPageSize(Integer pageSize) {
    this.pageSize = Optional.ofNullable(pageSize).filter(p -> p > 0).orElse(10);
  }

}
